package repository_impl

import (
	base "ginfwk/adapter/base/repository"
	"ginfwk/domain/model/entity"
	"ginfwk/domain/repository"
	"ginfwk/domain/repository/convertor"
	"ginfwk/infrastructure/do"
)

// UserRepositoryImpl 做各表信息的整体性聚合(比如1->N关联)
type UserRepositoryImpl struct {
	base.BaseRepository[do.UserDO]

	userConvertor *convertor.UserConvertor
}

// NewUserRepository 依赖注入入口
func NewUserRepository() repository.UserRepository {
	return &UserRepositoryImpl{}
}

func (u *UserRepositoryImpl) GetUserInfo(id int) *entity.UserEntity {
	userDO := u.SelectById(id)
	return u.userConvertor.ToUserEntity(userDO)
}

func (u *UserRepositoryImpl) GetUserList(ids []int) []*entity.UserEntity {
	users := u.SelectByIds(ids)
	return u.userConvertor.ToUserEntityList(users)
}
